From: Timm Bäder Date: Tue, 6 Mar 2018 16:44:33 +0000 (+0100) Subject: expander: fix sizes in resize_toplevel X-Git-Tag: archive/raspbian/3.24.39-1+rpi1~1^2~65^2~37^2~22 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=46828f8e0aa7b03497706d90f2aacc1a9423939e;p=gtk%2B3.0.git expander: fix sizes in resize_toplevel We can't use gtk_widget_get_allocation for either non-anchored widgets (which happens with the child widget when the expander is unexpanded) nor toplevel windows since that will include the window decorations. Fixes #70 in gtk3 --- diff --git a/gtk/gtkexpander.c b/gtk/gtkexpander.c index cd77178f01..b47f485934 100644 --- a/gtk/gtkexpander.c +++ b/gtk/gtkexpander.c @@ -1030,30 +1030,23 @@ gtk_expander_resize_toplevel (GtkExpander *expander) { GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (expander)); - if (toplevel && gtk_widget_get_realized (toplevel)) + if (toplevel && GTK_IS_WINDOW (toplevel) && + gtk_widget_get_realized (toplevel)) { - GtkAllocation toplevel_allocation; - GtkAllocation child_allocation; + int toplevel_width, toplevel_height; + int child_height; - gtk_widget_get_allocation (toplevel, &toplevel_allocation); - gtk_widget_get_allocation (child, &child_allocation); + gtk_widget_get_preferred_height (child, &child_height, NULL); + gtk_window_get_size (GTK_WINDOW (toplevel), &toplevel_width, &toplevel_height); if (priv->expanded) - { - GtkRequisition child_requisition; - - gtk_widget_get_preferred_height_for_width (child, child_allocation.width, &child_requisition.height, NULL); - - toplevel_allocation.height += child_requisition.height; - } + toplevel_height += child_height; else - { - toplevel_allocation.height -= child_allocation.height; - } + toplevel_height -= child_height; gtk_window_resize (GTK_WINDOW (toplevel), - toplevel_allocation.width, - toplevel_allocation.height); + toplevel_width, + toplevel_height); } } }